package cn.lzit.session;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/OrderServlet")
public class OrderServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");

        String foodChoice = request.getParameter("choice");
        HttpSession session = request.getSession();

        if (foodChoice != null) {
            session.setAttribute(foodChoice, foodChoice);
        }

        String url = "<A href='CartServlet'>欢迎去购物车页面！</A>";
        response.getWriter().print("<P>点击超链接，链接到购物车页面,去查看购物车中的商品。<br />" + url);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }
}